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

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

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

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

i = A("i")
j = B("j")
h = C("h")
b = D("b")
f = B("f")

i.o = h
i.t = h
j.p = f
j.y = h
h.r = j
h.o = j
b.u = i
b.x = i
f.p = j
f.y = h
assert f.p.y.o.y.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.t: C = None
        self.txt = txt

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

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

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

i = A("i")
j = B("j")
h = C("h")
b = D("b")
f = B("f")

i.o = h
i.t = h
j.p = f
j.y = h
h.r = j
h.o = j
b.u = i
b.x = i
f.p = j
f.y = h
assert f.p.y.o.y.o.txt == "j"