class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: D = None
        self.z: D = None
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

d = A("d")
k = B("k")
j = C("j")
b = D("b")
g = E("g")
a = F("a")
m = D("m")

d.q = j
d.u = j
d.s = b
d.z = m
k.v = b
j.s = d
j.v = d
j.w = d
j.x = b
b.w = d
b.t = a
g.w = j
a.q = d
m.w = d
m.t = a
assert d.u.v.u.v.s.w.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: C = None
        self.s: D = None
        self.z: D = None
        self.u: C = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.v: D = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.w: A = None
        self.t: F = None
        self.txt = txt

class E:
    def __init__(self, txt: str):
        self.w: C = None
        self.txt = txt

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

d = A("d")
k = B("k")
j = C("j")
b = D("b")
g = E("g")
a = F("a")
m = D("m")

d.q = j
d.u = j
d.s = b
d.z = m
k.v = b
j.s = d
j.v = d
j.w = d
j.x = b
b.w = d
b.t = a
g.w = j
a.q = d
m.w = d
m.t = a
assert d.u.v.u.v.s.w.q.txt == "j"