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

class B:
    def __init__(self, txt: str):
        self.x: A = 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.s: B = None
        self.p: B = None
        self.txt = txt

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

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

d = A("d")
n = B("n")
a = C("a")
e = D("e")
h = E("h")
j = F("j")
g = D("g")

d.t = n
d.y = a
d.q = g
n.x = d
a.w = h
e.s = n
e.p = n
h.u = j
h.t = n
j.u = h
g.s = n
g.p = n
assert e.p.x.q.txt == "
class A:
    def __init__(self, txt: str):
        self.t: B = None
        self.y: C = None
        self.q: D = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.x: A = 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.s: B = None
        self.p: B = None
        self.txt = txt

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

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

d = A("d")
n = B("n")
a = C("a")
e = D("e")
h = E("h")
j = F("j")
g = D("g")

d.t = n
d.y = a
d.q = g
n.x = d
a.w = h
e.s = n
e.p = n
h.u = j
h.t = n
j.u = h
g.s = n
g.p = n
assert e.p.x.q.txt == "g"