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

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: F = None
        self.v: B = None
        self.s: E = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

f = A("f")
j = B("j")
a = C("a")
k = D("k")
g = E("g")
b = F("b")
n = B("n")

f.t = k
f.y = b
f.q = b
f.p = j
j.p = b
a.w = n
a.v = n
a.x = b
a.s = g
k.t = g
k.x = g
g.s = f
g.z = a
b.r = k
n.p = b
assert b.r.x.s.p.p.r.x.txt == "
class A:
    def __init__(self, txt: str):
        self.t: D = None
        self.y: F = None
        self.p: B = None
        self.q: F = None
        self.txt = txt

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

class C:
    def __init__(self, txt: str):
        self.w: B = None
        self.x: F = None
        self.v: B = None
        self.s: E = None
        self.txt = txt

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

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

class F:
    def __init__(self, txt: str):
        self.r: D = None
        self.txt = txt

f = A("f")
j = B("j")
a = C("a")
k = D("k")
g = E("g")
b = F("b")
n = B("n")

f.t = k
f.y = b
f.q = b
f.p = j
j.p = b
a.w = n
a.v = n
a.x = b
a.s = g
k.t = g
k.x = g
g.s = f
g.z = a
b.r = k
n.p = b
assert b.r.x.s.p.p.r.x.txt == "g"