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

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: B = None
        self.q: A = None
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.w: D = None
        self.txt = txt

f = A("f")
k = B("k")
b = C("b")
i = D("i")
c = B("c")
n = A("n")
e = D("e")
j = D("j")
g = B("g")

f.q = g
k.z = j
k.t = c
b.o = g
b.w = k
b.q = n
b.x = j
i.z = n
i.w = e
c.z = j
c.t = g
n.q = c
e.z = f
e.w = j
j.z = f
j.w = i
g.z = i
g.t = c
assert b.x.z.q.z.w.z.txt == "
class A:
    def __init__(self, txt: str):
        self.q: B = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: B = None
        self.q: A = None
        self.x: D = None
        self.txt = txt

class D:
    def __init__(self, txt: str):
        self.z: A = None
        self.w: D = None
        self.txt = txt

f = A("f")
k = B("k")
b = C("b")
i = D("i")
c = B("c")
n = A("n")
e = D("e")
j = D("j")
g = B("g")

f.q = g
k.z = j
k.t = c
b.o = g
b.w = k
b.q = n
b.x = j
i.z = n
i.w = e
c.z = j
c.t = g
n.q = c
e.z = f
e.w = j
j.z = f
j.w = i
g.z = i
g.t = c
assert b.x.z.q.z.w.z.txt == "f"