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

class B:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: A = None
        self.z: A = None
        self.q: F = None
        self.x: E = None
        self.y: B = None
        self.v: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: A = None
        self.s: D = None
        self.y: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

a = A("a")
l = B("l")
g = C("g")
m = D("m")
f = E("f")
e = F("e")
h = G("h")

a.u = l
l.p = f
g.w = f
m.p = a
m.o = a
m.z = a
m.q = e
m.x = f
m.y = l
m.v = l
f.q = a
e.v = g
e.p = a
e.s = m
e.y = h
h.z = f
assert l.p.q.u.p.q.u.p.txt == "
class A:
    def __init__(self, txt: str):
        self.u: B = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.p: E = None
        self.txt = txt

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

class D:
    def __init__(self, txt: str):
        self.p: A = None
        self.o: A = None
        self.z: A = None
        self.q: F = None
        self.x: E = None
        self.y: B = None
        self.v: B = None
        self.txt = txt

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

class F:
    def __init__(self, txt: str):
        self.v: C = None
        self.p: A = None
        self.s: D = None
        self.y: G = None
        self.txt = txt

class G:
    def __init__(self, txt: str):
        self.z: E = None
        self.txt = txt

a = A("a")
l = B("l")
g = C("g")
m = D("m")
f = E("f")
e = F("e")
h = G("h")

a.u = l
l.p = f
g.w = f
m.p = a
m.o = a
m.z = a
m.q = e
m.x = f
m.y = l
m.v = l
f.q = a
e.v = g
e.p = a
e.s = m
e.y = h
h.z = f
assert l.p.q.u.p.q.u.p.txt == "f"