class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.y: D = None
        self.s: A = None
        self.txt = txt

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

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

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

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

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

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

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

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

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

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

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

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

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

f.q = b
f.y = l
f.s = n
b.y = d
b.o = m
m.y = f
m.r = h
m.q = l
m.z = d
l.t = b
d.o = h
h.x = b
n.q = b
n.y = l
n.s = f
assert b.o.z.o.txt == "h"