class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: E = None
        self.w: E = None
        self.y: B = None
        self.q: B = None
        self.z: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: F = None
        self.r: F = None
        self.y: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: B = None
        self.t: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: C = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.z: C = None
        self.o: A = None
        self.t: B = None
        self.w: B = None
        self.p: D = None
        self.txt = txt

b = A("b")
f = B("f")
h = C("h")
d = D("d")
c = E("c")
n = F("n")

b.o = f
b.y = f
b.q = f
b.p = c
b.w = c
b.z = d
f.x = n
f.r = n
f.y = n
h.r = d
h.t = d
h.w = f
d.o = h
d.s = h
c.z = h
n.z = h
n.o = b
n.t = f
n.w = f
n.p = d
assert b.q.x.t.r.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.p: E = None
        self.w: E = None
        self.y: B = None
        self.q: B = None
        self.z: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: F = None
        self.r: F = None
        self.y: F = None
        self.txt = txt

class C:
    def __init__(self, txt: str):
        self.r: D = None
        self.w: B = None
        self.t: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.o: C = None
        self.s: C = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.z: C = None
        self.o: A = None
        self.t: B = None
        self.w: B = None
        self.p: D = None
        self.txt = txt

b = A("b")
f = B("f")
h = C("h")
d = D("d")
c = E("c")
n = F("n")

b.o = f
b.y = f
b.q = f
b.p = c
b.w = c
b.z = d
f.x = n
f.r = n
f.y = n
h.r = d
h.t = d
h.w = f
d.o = h
d.s = h
c.z = h
n.z = h
n.o = b
n.t = f
n.w = f
n.p = d
assert b.q.x.t.r.txt == "n"