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

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

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

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

e.o = h
e.s = d
d.q = e
d.u = e
d.r = h
g.v = h
g.z = i
j.v = e
j.z = i
h.o = e
h.s = d
i.v = h
i.z = g
assert j.v.o.o.txt == "
class A:
    def __init__(self, txt: str):
        self.o: A = None
        self.s: B = None
        self.txt = txt

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

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

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

e.o = h
e.s = d
d.q = e
d.u = e
d.r = h
g.v = h
g.z = i
j.v = e
j.z = i
h.o = e
h.s = d
i.v = h
i.z = g
assert j.v.o.o.txt == "e"