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

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

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

g = A("g")
b = B("b")
h = C("h")
f = A("f")
k = B("k")
d = C("d")
c = B("c")

g.p = d
g.u = f
g.y = k
b.u = g
b.o = d
h.r = d
h.q = d
h.v = k
f.p = d
f.u = g
f.y = k
k.u = g
k.o = h
d.r = h
d.q = h
d.v = b
c.u = g
c.o = d
assert g.p.v.o.q.q.txt == "
class A:
    def __init__(self, txt: str):
        self.p: C = None
        self.u: A = None
        self.y: B = None
        self.txt = txt

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

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

g = A("g")
b = B("b")
h = C("h")
f = A("f")
k = B("k")
d = C("d")
c = B("c")

g.p = d
g.u = f
g.y = k
b.u = g
b.o = d
h.r = d
h.q = d
h.v = k
f.p = d
f.u = g
f.y = k
k.u = g
k.o = h
d.r = h
d.q = h
d.v = b
c.u = g
c.o = d
assert g.p.v.o.q.q.txt == "d"