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

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.p: A = None
        self.u: C = None
        self.v: D = None
        self.s: C = None
        self.txt = txt

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

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

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

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

d = A("d")
g = B("g")
e = C("e")
a = D("a")
i = E("i")
n = F("n")
b = A("b")

d.u = i
g.r = i
g.p = d
g.u = e
g.s = e
g.v = a
e.s = d
a.w = d
a.p = d
a.s = b
i.t = d
n.q = g
n.u = e
b.u = i
assert g.p.u.t.u.t.txt == "
class A:
    def __init__(self, txt: str):
        self.u: E = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.r: E = None
        self.p: A = None
        self.u: C = None
        self.v: D = None
        self.s: C = None
        self.txt = txt

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

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

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

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

d = A("d")
g = B("g")
e = C("e")
a = D("a")
i = E("i")
n = F("n")
b = A("b")

d.u = i
g.r = i
g.p = d
g.u = e
g.s = e
g.v = a
e.s = d
a.w = d
a.p = d
a.s = b
i.t = d
n.q = g
n.u = e
b.u = i
assert g.p.u.t.u.t.txt == "d"