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

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

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

i = A("i")
g = B("g")
e = C("e")
d = C("d")
j = C("j")
c = B("c")

i.o = j
i.u = d
g.o = i
g.x = i
g.p = c
e.y = j
e.v = j
d.y = e
d.v = j
j.y = d
j.v = d
c.o = i
c.x = i
c.p = g
assert d.y.v.y.txt == "
class A:
    def __init__(self, txt: str):
        self.o: C = None
        self.u: C = None
        self.txt = txt

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

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

i = A("i")
g = B("g")
e = C("e")
d = C("d")
j = C("j")
c = B("c")

i.o = j
i.u = d
g.o = i
g.x = i
g.p = c
e.y = j
e.v = j
d.y = e
d.v = j
j.y = d
j.v = d
c.o = i
c.x = i
c.p = g
assert d.y.v.y.txt == "d"