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

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

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

d = A("d")
j = B("j")
h = C("h")
a = C("a")
g = A("g")
c = A("c")
l = C("l")
k = B("k")

d.y = g
j.q = d
h.y = g
h.x = g
h.v = l
a.y = g
a.v = l
a.x = d
g.y = d
c.y = d
l.y = g
l.v = a
l.x = d
k.q = c
assert c.y.y.y.y.txt == "
class A:
    def __init__(self, txt: str):
        self.y: A = None
        self.txt = txt

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

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

d = A("d")
j = B("j")
h = C("h")
a = C("a")
g = A("g")
c = A("c")
l = C("l")
k = B("k")

d.y = g
j.q = d
h.y = g
h.x = g
h.v = l
a.y = g
a.v = l
a.x = d
g.y = d
c.y = d
l.y = g
l.v = a
l.x = d
k.q = c
assert c.y.y.y.y.txt == "g"