class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.w: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.w: F = None
        self.x: E = None
        self.o: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

f = A("f")
c = B("c")
j = C("j")
h = D("h")
e = E("e")
i = F("i")

f.u = i
f.w = e
c.r = e
j.r = e
j.x = e
j.w = i
j.o = f
h.u = j
h.y = e
e.p = j
i.x = e
assert h.y.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.u: F = None
        self.w: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: E = None
        self.w: F = None
        self.x: E = None
        self.o: A = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.u: C = None
        self.y: E = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.p: C = None
        self.txt = txt

class F:
    def __init__(self, txt: str):
        self.x: E = None
        self.txt = txt

f = A("f")
c = B("c")
j = C("j")
h = D("h")
e = E("e")
i = F("i")

f.u = i
f.w = e
c.r = e
j.r = e
j.x = e
j.w = i
j.o = f
h.u = j
h.y = e
e.p = j
i.x = e
assert h.y.p.w.txt == "i"