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

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

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

m = A("m")
g = B("g")
d = C("d")
e = A("e")
j = C("j")
h = C("h")
b = C("b")
f = B("f")
a = B("a")
i = A("i")

m.o = g
m.u = i
g.s = d
d.y = i
d.v = j
e.o = f
e.u = m
j.y = e
j.v = b
h.y = e
h.v = b
b.y = m
b.v = d
f.s = d
a.s = j
i.o = g
i.u = e
assert g.s.y.u.txt == "
class A:
    def __init__(self, txt: str):
        self.o: B = None
        self.u: A = None
        self.txt = txt

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

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

m = A("m")
g = B("g")
d = C("d")
e = A("e")
j = C("j")
h = C("h")
b = C("b")
f = B("f")
a = B("a")
i = A("i")

m.o = g
m.u = i
g.s = d
d.y = i
d.v = j
e.o = f
e.u = m
j.y = e
j.v = b
h.y = e
h.v = b
b.y = m
b.v = d
f.s = d
a.s = j
i.o = g
i.u = e
assert g.s.y.u.txt == "e"