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

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

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

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

e = A("e")
b = B("b")
j = C("j")
d = D("d")
h = A("h")

e.z = b
b.r = h
j.o = b
d.t = h
h.z = b
assert j.o.r.z.r.txt == "
class A:
    def __init__(self, txt: str):
        self.z: B = None
        self.txt = txt

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

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

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

e = A("e")
b = B("b")
j = C("j")
d = D("d")
h = A("h")

e.z = b
b.r = h
j.o = b
d.t = h
h.z = b
assert j.o.r.z.r.txt == "h"