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

class B:
    def __init__(self, txt: str):
        self.s: E = None
        self.t: C = None
        self.r: E = None
        self.txt = txt

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

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

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

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

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

j.q = c
j.p = d
j.s = m
a.s = c
a.r = c
a.t = b
b.u = m
b.s = c
b.p = j
d.w = b
c.t = m
m.q = j
m.s = b
assert b.u.q.q.t.q.txt == "
class A:
    def __init__(self, txt: str):
        self.q: E = None
        self.p: D = None
        self.s: F = None
        self.txt = txt

class B:
    def __init__(self, txt: str):
        self.s: E = None
        self.t: C = None
        self.r: E = None
        self.txt = txt

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

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

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

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

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

j.q = c
j.p = d
j.s = m
a.s = c
a.r = c
a.t = b
b.u = m
b.s = c
b.p = j
d.w = b
c.t = m
m.q = j
m.s = b
assert b.u.q.q.t.q.txt == "j"