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

class B:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: B = None
        self.u: A = None
        self.txt = txt

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

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

e = A("e")
b = B("b")
g = C("g")
j = D("j")
c = D("c")
f = B("f")
h = D("h")

e.y = h
e.o = c
b.o = f
b.w = f
b.u = e
g.u = e
j.t = g
j.p = e
c.t = g
c.p = e
f.o = b
f.w = b
f.u = e
h.t = g
h.p = e
assert b.o.o.u.y.p.y.t.txt == "
class A:
    def __init__(self, txt: str):
        self.y: D = None
        self.o: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.o: B = None
        self.w: B = None
        self.u: A = None
        self.txt = txt

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

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

e = A("e")
b = B("b")
g = C("g")
j = D("j")
c = D("c")
f = B("f")
h = D("h")

e.y = h
e.o = c
b.o = f
b.w = f
b.u = e
g.u = e
j.t = g
j.p = e
c.t = g
c.p = e
f.o = b
f.w = b
f.u = e
h.t = g
h.p = e
assert b.o.o.u.y.p.y.t.txt == "g"