class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.q: C = None
        self.z: D = None
        self.r: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: F = None
        self.p: D = None
        self.x: D = None
        self.w: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

a = A("a")
l = B("l")
h = C("h")
b = D("b")
n = E("n")
j = F("j")

a.o = n
a.q = h
a.r = h
a.z = b
l.q = j
l.p = b
l.x = b
l.w = n
h.q = a
b.x = n
b.p = l
b.q = h
n.u = b
j.x = b
assert h.q.z.p.w.txt == "
class A:
    def __init__(self, txt: str):
        self.o: E = None
        self.q: C = None
        self.z: D = None
        self.r: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.q: F = None
        self.p: D = None
        self.x: D = None
        self.w: E = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.q: A = None
        self.txt = txt

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

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

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

a = A("a")
l = B("l")
h = C("h")
b = D("b")
n = E("n")
j = F("j")

a.o = n
a.q = h
a.r = h
a.z = b
l.q = j
l.p = b
l.x = b
l.w = n
h.q = a
b.x = n
b.p = l
b.q = h
n.u = b
j.x = b
assert h.q.z.p.w.txt == "n"