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

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

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

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

e = A("e")
m = B("m")
h = C("h")
a = D("a")
g = C("g")
i = A("i")
j = A("j")
b = D("b")

e.t = h
e.o = g
m.x = b
m.p = j
h.r = g
h.w = b
a.z = b
g.r = h
g.w = b
i.t = h
i.o = g
j.t = h
j.o = h
b.z = a
assert g.w.z.z.txt == "
class A:
    def __init__(self, txt: str):
        self.t: C = None
        self.o: C = None
        self.txt = txt

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

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

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

e = A("e")
m = B("m")
h = C("h")
a = D("a")
g = C("g")
i = A("i")
j = A("j")
b = D("b")

e.t = h
e.o = g
m.x = b
m.p = j
h.r = g
h.w = b
a.z = b
g.r = h
g.w = b
i.t = h
i.o = g
j.t = h
j.o = h
b.z = a
assert g.w.z.z.txt == "b"