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

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

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

a = A("a")
c = B("c")
g = C("g")
j = A("j")
n = C("n")
h = B("h")
e = B("e")
b = B("b")
d = A("d")

a.z = g
a.x = n
c.w = d
g.s = n
g.x = n
j.z = n
j.x = n
n.s = g
n.x = g
h.w = d
e.w = a
b.w = a
d.z = g
d.x = g
assert d.x.x.x.txt == "
class A:
    def __init__(self, txt: str):
        self.z: C = None
        self.x: C = None
        self.txt = txt

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

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

a = A("a")
c = B("c")
g = C("g")
j = A("j")
n = C("n")
h = B("h")
e = B("e")
b = B("b")
d = A("d")

a.z = g
a.x = n
c.w = d
g.s = n
g.x = n
j.z = n
j.x = n
n.s = g
n.x = g
h.w = d
e.w = a
b.w = a
d.z = g
d.x = g
assert d.x.x.x.txt == "g"